<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        ul,ol{
            list-style: none;
        }
        html,body,ul{
            width: 100%;
            height: 100%;
        }
        ul li{
            width: 100%;
            height: 100%;
            background-color: yellow;
        }
        ol{
            position: fixed;
            top: 100px;
            left: 50px;
            
        }
        ol li{
            width: 50px;
            height: 50px;
            border: 1px solid #000;
            text-align: center;
            line-height: 50px;
            margin-top: -1px;
        }
    </style>
</head>
<body>
    <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
    </ul>
    <ol>
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
    </ol>
</body>
</html>
<script>
    var lis = document.querySelectorAll('ul>li')
    var ois = document.querySelectorAll('ol>li')

    var bgc = ['red','orange','yellow','green','blue']
    var target = 0
    var leader = 0
    var timer = null
    ois.forEach((item,index)=>{
        item.style.backgroundColor = bgc[index]
        lis[index].style.backgroundColor = bgc[index]

        ois[index].onclick = function(){
            clearInterval(timer)
            target = lis[index].offsetTop
            timer = setInterval(() => {
                leader = leader + (target - leader)/10
                // scrollTo(参数1，参数2)
                // 参数1：x方向 滚动距离
                // 参数1：Y方向 滚动距离
                window.scrollTo(0,leader)
            }, 30);
        }
    })
    
</script>